package net.dodoman.thread;

public class TwoThread {

	public static int COUNT;

	public static void main(String[] args) {
		Thread first = new FirstThread();
		Thread second = new SecondThread();
		System.out.println("main thread");
		first.start();
		second.start();
	}
}

class FirstThread extends Thread {
	@Override
	public void run() {
		while (true) {
			System.out.println("First Print");
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			TwoThread.COUNT++;
			if (TwoThread.COUNT > 10)
				break;
		}
	}
}

class SecondThread extends Thread {
	@Override
	public void run() {
		while (true) {
			System.out.println("Second Print");
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			TwoThread.COUNT++;
			if (TwoThread.COUNT > 10)
				break;
		}
	}
}